package com.miage.forum.session;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.miage.forum.entities.Categorie;
@Stateless
public class gestionCategorieBean implements gestionCategorie {
	
	@PersistenceContext
	EntityManager em;
	public void ajouter(Categorie cat) {
		em.persist(cat);

	}

	@Override
	public List<Categorie> lister() {
		
		return em.createQuery("select c from Categorie c").getResultList();
	}

	@Override
	public Categorie rechercher(int idCategorie) {
		
		return em.find(Categorie.class, idCategorie);
	}

}
